<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/sys/include.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<title>菜单管理</title>
<link href="css/global.css" type="text/css" rel="stylesheet"/>

	<link rel="stylesheet" type="text/css" href="css/easydialog.css" />
	<script src="js/easydialog.min.js" type="text/javascript"></script>
	<script src="js/jquery-1.5.1.js" type="text/javascript"></script>
	<script src="js/jquery.form.js" type="text/javascript"></script>
	<script src="js/jquery.validate.js" type="text/javascript"></script>
	<script src="js/jquery.validate.ms.js" type="text/javascript"></script>

<style type="text/css">
<!--
body{
	background-color:#ffffff;
	margin:0px; padding:0px;
}
#parentID{
	width: 155px;
}
label.error{
	font-weight: bold;
	color: red;
}
-->
</style>
</head>

	<body>
	<div id="main">

	<div id="part1" class="part">
		<p class="title"><a href="#">添加菜单</a></p>
		<div class="doc" id="doc2">
				<form id="addDataId">
				<ta:formToken/>
			<table>
				<tr><td>名称:</td><td><input id="name" name="name" type="text" class="txt" /></td></tr>
				<tr><td>地址:</td><td><input id="url" name="url" type="text" class="txt"  /></td></tr>
				<tr><td>上级菜单:</td><td>
				<select id="parentID" name="parentID">
				<%--
				<option value="" selected="selected"></option>
				 --%>
				<c:forEach items="${pmenus}" var="menu">
				<option value="${menu.id}">${menu.name}</option>
				</c:forEach>
				</select>
				
				</td></tr>
				<%--
				<tr><td>序号:</td><td><input id="orderNum" name="orderNum" type="text" class="txt"  /></td></tr>
				 --%>
				<tr><td>描述:</td><td><input id="description" name="description" type="text" class="txt" /></td></tr>
			</tr>
			<tr>
			<td><input value="提交" type="button" id="submitId" class="btn"/> 
				<input value="重置" type="button" id="resetId" class="btn"/></td><td></td>
			</tr>
			</table>	
				
				</form>
		</div>
	</div>
	
	</div>
	</body>
	
		<script type="text/javascript">
$(document).ready(function(){
	var validator = $("#addDataId").validate({
		success: function(label) {
			label.html("<font color='green'>正确！</font>");
		},
		rules: {
			name:{
				required:true
			},
			description:{
				required:true
			}
			
		}
	});
	
	$('#submitId').click(function(){
			if(true == validator.form()){
				var options = {
					url:'sysMenuAddAction.do',
					type:'POST',
					success:function(data) {
		         		if("true" == data){
		         			
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交成功！',
									yesFn : function(){
		         							//return true;
		         							window.location="sysMenuQuery.do";
		         							window.reload();
		         							}
								}
							});
									         			
		         		}else if("repeatSubmit" == data){
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据已提交，请不要重复操作！',
									yesFn : function(){return true;}
								}
							});
		         		}else{
		         			
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交失败！',
									yesFn : function(){return true;}
								}
							});
		         		}
		     		}
				};
				$('#addDataId').ajaxSubmit(options);
				return false;
			}else{
				return false;
			}
	    });

	$("#resetId").click(function() {
        validator.resetForm();
    });
});
</script>
</html>

